#include <iostream>

#include <string>

#include <sstream>

#include <vector>

int Split(const std::string &str, const std::string &sep, std::vector<std::string> *array){
    size_t start = 0, pos = 0;
    int count = 0;
    while(1){
        pos = str.find(sep,start);
            if(pos == std::string::npos){
                break;
            }
        array->push_back(str.substr(start, pos - start));
        start =  pos+ sep.size();
        ++count;
    }

    if(start<str.size()){
        // 说明还有数据
        array->push_back(str.substr(start));
        ++count;
    }
    return count;
}


void SplitTest() {
    std::string str = "a.txt a.txt-18-123124\r\nb.txt b.txt-23-333333\r\nc.txt c.txt-99-454545\r\nd.txt d.txt-56-565656\r\n";
    std::vector<std::string> vstr;

    Split(str, "\r\n", &vstr);

    for (const auto &it : vstr) { // 打印结果
        std::cout << it << std::endl;
    }

    



}


int main()
{
    // std::cout << "Hello world" << std::endl;
    

    SplitTest();


    return 0;
}

